import React, { Component } from 'react';
import Modal from './components/Modal'
import './App.css'

class App extends Component {
  state = {
    count: 1,
    visible: false,
  }
  openModal() {
    this.setState({
      visible: true
    })
  }
  closeModal = () => {
    this.setState({
      visible: false
    })
  }
  okClick = () => {
    this.addCount()
  }
  addCount = () => {
    const { count } = this.state
    this.setState({
      count: count + 1
    })
  }
  render() {
    const { count, visible } = this.state
    return (
      <div>
        <h1>{count}</h1>
        <button onClick={ () => this.openModal() }>+1</button>
        <Modal 
          visible={visible} 
          closeModal={ this.closeModal } 
          okClick={ this.okClick } 
          title={ [1,2,3,4,5] }
          okValue="ok"
        >
          <h1>今天天气还不错！！！</h1>
          <h2>为啥？？？</h2>
          <h3>因为没有下雨！！！！</h3>
        </Modal>
      </div>
    );
  }
}

export default App;
